# This code replicates Table 3
rm(list=ls())
setwd("")
library(foreign)
data <- read.dta("data.dta")

column1 <- rbind(100-100*table(data$exp4_swayed)[1]/(table(data$exp4_swayed)[1]+table(data$exp4_swayed)[2]),100*table(data$exp4_swayed)[1]/(table(data$exp4_swayed)[1]+table(data$exp4_swayed)[2]))
column2 <- rbind(100*mean(table(data$state_projects_hospital)[2]/(table(data$state_projects_hospital)[1]+table(data$state_projects_hospital)[2]),
                  table(data$state_projects_school)[2]/(table(data$state_projects_school)[1]+table(data$state_projects_school)[2]),
                  table(data$state_projects_infrastructure)[2]/(table(data$state_projects_infrastructure)[1]+table(data$state_projects_infrastructure)[2]),
                  table(data$state_projects_water)[2]/(table(data$state_projects_water)[1]+table(data$state_projects_water)[2])), 100-100*mean(table(data$state_projects_hospital)[2]/(table(data$state_projects_hospital)[1]+table(data$state_projects_hospital)[2]),
                  table(data$state_projects_school)[2]/(table(data$state_projects_school)[1]+table(data$state_projects_school)[2]),
                  table(data$state_projects_infrastructure)[2]/(table(data$state_projects_infrastructure)[1]+table(data$state_projects_infrastructure)[2]),
                  table(data$state_projects_water)[2]/(table(data$state_projects_water)[1]+table(data$state_projects_water)[2])))

column3 <- rbind(100*mean(table(data$community_projects_health)[2]/(table(data$community_projects_health)[1]+table(data$community_projects_health)[2]),
         table(data$community_projects_education)[2]/(table(data$community_projects_education)[1]+table(data$community_projects_education)[2]),
         table(data$community_projects_confidence)[2]/(table(data$community_projects_confidence)[1]+table(data$community_projects_confidence)[2]),
         table(data$community_projects_water)[2]/(table(data$community_projects_water)[1]+table(data$community_projects_water)[2]),
         table(data$community_projects_church)[2]/(table(data$community_projects_church)[1]+table(data$community_projects_church)[2])), 100-100*mean(table(data$community_projects_health)[2]/(table(data$community_projects_health)[1]+table(data$community_projects_health)[2]),
         table(data$community_projects_education)[2]/(table(data$community_projects_education)[1]+table(data$community_projects_education)[2]),
         table(data$community_projects_confidence)[2]/(table(data$community_projects_confidence)[1]+table(data$community_projects_confidence)[2]),
         table(data$community_projects_water)[2]/(table(data$community_projects_water)[1]+table(data$community_projects_water)[2]),
         table(data$community_projects_church)[2]/(table(data$community_projects_church)[1]+table(data$community_projects_church)[2])))


table <- round(cbind(column1, column2, column3),1)
colnames(table) <- c("Persuaded by authority?", "Deems state projects important?", "Deems village projects important?")
rownames(table) <- c("Yes", "No")
table